package com.alizhezi.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.orhanobut.logger.Logger

import org.greenrobot.eventbus.EventBus

/**
 * Copyright (C) 2019 The ailizhezi.com Inc. All rights reserved
 * Author: 吕鹏 gavin6116@gmail.com
 * Time Created at 2019-10-24
 * Description：
 */
open class MoLuBaseActivity : AppCompatActivity() {
    protected var TAG=this.javaClass.simpleName
    private var TAG_BASE="MoLuBaseActivity"

    /****
     * @return true:注册EventBus
     * return false:反注册  EventBus
     */
    open fun isUseEventBus(): Boolean {
        return false
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Logger.t(TAG_BASE).d("onCreate")
        Logger.t(TAG).d("onCreate")
    }

    override fun onStart() {
        super.onStart()
         Logger.t(TAG_BASE).d("onStart")
         Logger.t(TAG).d("onStart")
        if (isUseEventBus()) {
            EventBus.getDefault().register(this)
        }
    }

    override fun onResume() {
        super.onResume()
         Logger.t(TAG_BASE).d("onResume")
         Logger.t(TAG).d("onResume")


    }

    override fun onPause() {
        super.onPause()
         Logger.t(TAG_BASE).d("onPause")
         Logger.t(TAG).d("onPause")

    }

    override fun onStop() {
        super.onStop()
         Logger.t(TAG_BASE).d("onStop")
         Logger.t(TAG).d("onStop")
        if (isUseEventBus()) {
            EventBus.getDefault().unregister(this)
        }
    }

    override fun onDestroy() {
        super.onDestroy()
         Logger.t(TAG).d("onDestroy")
         Logger.t(TAG_BASE).d("onDestroy")
    }
}